import Vue from "vue";
import VueI18n from "vue-i18n";
import App from "./App.vue";
import router from "./route";
import store from "./store/";
import enUS from "@/locale/enUS";
import zhCN from "@/locale/zhCN";
import queryString from "query-string";

//https://www.antdv.com/docs/vue/introduce-cn/#按需加载
import {
  Button,
  Layout,
  Icon,
  Drawer,
  Radio,
  Menu,
  Form,
  Input,
  Select,
  LocaleProvider,
  Dropdown,
  DatePicker
} from "ant-design-vue"; //通过配置babel，实现按需加载控件
import Authorized from "@/components/Authorized";
import Auth from "@/directives/auth";

Vue.config.productionTip = false;

//使用vue组件
Vue.use(Button);
Vue.use(Layout);
Vue.use(Icon);
Vue.use(Drawer);
Vue.use(Radio);
Vue.use(Menu);
Vue.use(Form);
Vue.use(Input);
Vue.use(Select);
Vue.use(LocaleProvider);
Vue.use(Dropdown);
Vue.use(DatePicker);

//使用自定义组件
Vue.component("Authorized", Authorized);

//使用指令
Vue.use(Auth);

//使用三方组件库
Vue.use(VueI18n);

const i18n = new VueI18n({
  locale: queryString.parse(location.search).locale || "zhCN",
  messages: {
    zhCN: { message: zhCN },
    enUS: { message: enUS }
  }
});

const IconFont = Icon.createFromIconfontCN({
  scriptUrl: "//at.alicdn.com/t/font_2384308_r6cfqipbx7q.js"
});
Vue.component("IconFont", IconFont);

new Vue({
  i18n,
  router,
  store,
  render: h => h(App)
}).$mount("#app");
